#include<iostream>
#include<cstring>
using namespace std;
const int N = 3e5 + 10, M = 3e5 + 10;
int n, m;
int h[N], e[M], ne[M], idx;
int g[N];
void add(int a, int b)
{
	e[idx] = b, ne[idx] = h[a], h[a] = idx++;
}

void dfs(int u)
{
	for (int i = h[u]; ~i; i = ne[i]) {
		int j = e[i];
		g[j] = max(g[j], g[u] - 1);
		dfs(j);
	}
}
int main()
{
	cin >> n >> m;
	memset(h, -1, sizeof(h));
	for (int i = 2; i <= n; i++) {
		int x;
		scanf("%d", &x);
		add(x, i);
	}
	while (m--) {
		int x, y;
		scanf("%d%d", &x, &y);
		g[x] = max(g[x], y + 1);
	}
	dfs(1);
	int ans = 0;
	for (int i = 1; i <= n; i++) {
		if (g[i])ans++;
	}
	cout << ans << endl;
	return 0;
}